//
//  PHMainViewController.m
//  ph
//
//  Created by weiduowang on 14-12-14.
//  Copyright (c) 2014年 weiduowang. All rights reserved.
//
#import "PHMainViewController.h"
#import "Unit.h"
#import "PHAirViewController.h"
#import "PHScrollViewController.h"
#import "PHSecondViewController.h"
#import "PHSecondViewController.h"
#import "PHAngleViewController.h"


@interface PHMainViewController ()


@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;


@end

@implementation PHMainViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}


- (void)leftButtonTouch
{
    [self.airViewController showAirViewFromViewController:self.navigationController complete:nil];
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"背景-"]];

    
    
    
    UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, screen_Width, screen_Height)];
    scrollView.contentSize=CGSizeMake(screen_Width, 212*6);
    scrollView.showsVerticalScrollIndicator=NO;
    [self.view addSubview:scrollView];
    
    
    for ( int i=0; i<6; i++)
    {
        UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
        button.frame=CGRectMake(0, 0+212*i, screen_Width, 212);
        button.tag=i+1;
        NSString *stringInt = [NSString stringWithFormat:@"%d",i];
        NSString *str=[NSString stringWithFormat:@"%@%@%@",@"tu-",stringInt,@"-"];
        [button setImage:[UIImage imageNamed:str] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(tapButton:) forControlEvents:UIControlEventTouchUpInside];
        [scrollView addSubview:button];
    }
    
    
    
    
    
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 44, 44);
    
    //    button.backgroundColor = [UIColor colorWithPatternImage:];
    [button setImage:[UIImage imageNamed:@"左上角-图标"] forState: UIControlStateNormal];
    [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(leftButtonTouch) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    
    
    
    //    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:92/255.0 green:91/255.0 blue:91/255.0 alpha:1]];
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:250/255.0 green:250/255.0 blue:250/255.0 alpha:1]];
    [[UINavigationBar appearance] setTranslucent:NO];
    
    [[UINavigationBar appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor colorWithRed:92/255.0 green:91/255.0 blue:91/255.0 alpha:1],
      UITextAttributeTextColor,
      [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],
      UITextAttributeTextShadowColor,
      //      [NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
      //      UITextAttributeTextShadowOffset,
      [UIFont fontWithName:@"Arial-Bold" size:0.0],
      UITextAttributeFont,
      nil]];
    self.title = @"酷拉丁精选";
    
    typeof(self) bself = self;
    self.phSwipeHander = ^{
        [bself.airViewController showAirViewFromViewController:bself.navigationController complete:nil];
    };
    
    
    
    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)tapButton:(UIButton*)button
{
    
    PHScrollViewController *sv = [[PHScrollViewController alloc] init];
    switch (button.tag) {
        case 5:
            sv = [[PHAngleViewController alloc] init];
            break;
        case 2:
            
            break;
        case 3:
            
            break;
        case 4:
            
            break;

    }
//    self.view.frame = CGRectMake(320, 0, 320, screen_Height);
    
//    [UIView animateWithDuration:KLongDuration animations:^{
//       
//        self.view.frame = CGRectMake(0, 0, 320, screen_Height);
//    }];
//    [self.view addSubview:sv.view];
//    [self addChildViewController:sv];
    [self.navigationController pushViewController:sv animated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/



@end
